<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<mat-expansion-panel data-testId="entrypoint-request" class="log" expanded="true" *ngIf="!!connectionLogDetail.entrypointRequest">
  <mat-expansion-panel-header class="log__header">
    <mat-panel-title class="log__header__title">Entrypoint Request</mat-panel-title>
  </mat-expansion-panel-header>

  <div class="log__data">
    <div class="log__row">
      <div class="log__row__cell">
        <div class="log__row__property">URI:</div>
        <div data-testId="uri-value" class="log__row__value">{{ connectionLogDetail?.entrypointRequest?.uri | lowercase }}</div>
      </div>
    </div>
    <div *ngIf="connectionLogDetail?.entrypointRequest?.method" class="log__row">
      <div class="log__row__cell">
        <div class="log__row__property">Method:</div>
        <div
          data-testId="method-value"
          class="{{ 'log__row__value gio-method-badge-' + connectionLogDetail.entrypointRequest.method.toLowerCase() }}"
        >
          {{ connectionLogDetail.entrypointRequest.method | lowercase }}
        </div>
      </div>
    </div>
    <div class="log__row" *ngIf="Object.keys(connectionLogDetail?.entrypointRequest?.headers).length > 0">
      <div class="log__row__cell">
        <div class="log__row__property">Headers:</div>
      </div>
      <div
        data-testId="header-value"
        class="log__row__sub-cell"
        *ngFor="let header of connectionLogDetail?.entrypointRequest?.headers | keyvalue"
      >
        <div class="log__row__property">{{ header.key }}:</div>
        <div class="log__row__value">{{ header.value }}</div>
      </div>
    </div>
  </div>
  <body-accordion
    *ngIf="connectionLogDetail?.entrypointRequest?.body"
    [body]="connectionLogDetail?.entrypointRequest?.body"
  ></body-accordion>
</mat-expansion-panel>
<mat-expansion-panel data-testId="endpoint-request" class="log" expanded="true" *ngIf="!!connectionLogDetail.endpointRequest">
  <mat-expansion-panel-header class="log__header">
    <div class="log__header__title">Endpoint Request</div>
  </mat-expansion-panel-header>

  <div class="log__data">
    <div class="log__row" *ngIf="connectionLogDetail?.endpointRequest?.uri != ''">
      <div class="log__row__cell">
        <div class="log__row__property">URI:</div>
        <div data-testId="uri-value" class="log__row__value">{{ connectionLogDetail?.endpointRequest?.uri | lowercase }}</div>
      </div>
    </div>
    <div *ngIf="connectionLogDetail?.endpointRequest?.method" class="log__row">
      <div class="log__row__cell">
        <div class="log__row__property">Method:</div>
        <div
          data-testId="method-value"
          class="{{ 'log__row__value gio-method-badge-' + connectionLogDetail.endpointRequest.method.toLowerCase() }}"
        >
          {{ connectionLogDetail.endpointRequest.method | lowercase }}
        </div>
      </div>
    </div>
    <div class="log__row" *ngIf="Object.keys(connectionLogDetail?.endpointRequest?.headers).length > 0">
      <div class="log__row__cell">
        <div class="log__row__property">Headers:</div>
      </div>
      <div
        data-testId="header-value"
        class="log__row__sub-cell"
        *ngFor="let header of connectionLogDetail?.endpointRequest?.headers | keyvalue"
      >
        <div class="log__row__property">{{ header.key }}:</div>
        <div class="log__row__value">{{ header.value }}</div>
      </div>
    </div>
  </div>
  <body-accordion *ngIf="connectionLogDetail?.endpointRequest?.body" [body]="connectionLogDetail?.endpointRequest?.body"></body-accordion>
</mat-expansion-panel>
<mat-expansion-panel data-testId="endpoint-response" class="log" expanded="true" *ngIf="!!connectionLogDetail.endpointResponse">
  <mat-expansion-panel-header class="log__header">
    <div class="log__header__title">Endpoint Response</div>
  </mat-expansion-panel-header>

  <div class="log__data">
    <div class="log__row">
      <div class="log__row__cell">
        <div class="log__row__property">Status:</div>
        <div
          data-testId="status-value"
          class="log__row__value"
          [class.gio-badge-warning]="connectionLogDetail?.endpointResponse?.status >= 400"
          [class.gio-badge-success]="connectionLogDetail?.endpointResponse?.status < 400"
        >
          {{ connectionLogDetail?.endpointResponse?.status }}
        </div>
      </div>
    </div>
    <div class="log__row" *ngIf="Object.keys(connectionLogDetail?.endpointResponse?.headers).length > 0">
      <div class="log__row__cell">
        <div class="log__row__property">Headers:</div>
      </div>
      <div
        data-testId="header-value"
        class="log__row__sub-cell"
        *ngFor="let header of connectionLogDetail?.endpointResponse?.headers | keyvalue"
      >
        <div class="log__row__property">{{ header.key }}:</div>
        <div class="log__row__value">{{ header.value }}</div>
      </div>
    </div>
  </div>
  <body-accordion *ngIf="connectionLogDetail?.endpointResponse?.body" [body]="connectionLogDetail?.endpointResponse?.body"></body-accordion>
</mat-expansion-panel>
<mat-expansion-panel data-testId="entrypoint-response" class="log" expanded="true" *ngIf="!!connectionLogDetail.entrypointResponse">
  <mat-expansion-panel-header class="log__header">
    <div class="log__header__title">Entrypoint Response</div>
  </mat-expansion-panel-header>

  <div class="log__data">
    <div class="log__row">
      <div class="log__row__cell">
        <div class="log__row__property">Status:</div>
        <div
          data-testId="status-value"
          class="log__row__value"
          [class.gio-badge-warning]="connectionLogDetail?.entrypointResponse?.status >= 400"
          [class.gio-badge-success]="connectionLogDetail?.entrypointResponse?.status < 400"
        >
          {{ connectionLogDetail?.entrypointResponse?.status }}
        </div>
      </div>
    </div>
    <div class="log__row" *ngIf="Object.keys(connectionLogDetail?.entrypointResponse?.headers).length > 0">
      <div class="log__row__cell">
        <div class="log__row__property">Headers:</div>
      </div>
      <div
        data-testId="header-value"
        class="log__row__sub-cell"
        *ngFor="let header of connectionLogDetail?.entrypointResponse?.headers | keyvalue"
      >
        <div class="log__row__property">{{ header.key }}:</div>
        <div class="log__row__value">{{ header.value }}</div>
      </div>
    </div>
  </div>
  <body-accordion
    class="log__row__accordion"
    *ngIf="connectionLogDetail?.entrypointResponse?.body"
    [body]="connectionLogDetail?.entrypointResponse?.body"
  ></body-accordion>
</mat-expansion-panel>
